<template>
	<view class="content">
    <umahead></umahead>
		<scroll-view scroll-y="true">
			<view class="item" v-for="(item, index) in musicList" :key="index" @click="goToList(item.id)">
				<view class="img">
					<image class="logo" :src="item.coverImgUrl"></image>
					<text class="update">{{ item.updateFrequency }}</text>
				</view>
				<view class="list">
					<view class="list-item" v-for="(song, i) in item.tracks" :key="i">
						<text class="list-item">{{i+1}}.{{song.first}}-{{song.second}}</text>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		toplist
	} from '../../common/api.js'
	export default {
		data() {
			return {
				musicList: [],
			}
		},
		onLoad() {
			toplist().then(res => {
				this.musicList = res
			})
		},
		methods: {
			goToList(id){
				uni.navigateTo({
					url:`/pages/list/list?listid=` + id
				});
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin-left: 30rpx;
	}

	.item {
		display: flex;
		margin-top: 30rpx;
	}

	.img {
		position: relative;
	}

	.logo {
		width: 212rpx;
		height: 230rpx;
		border-radius: 10rpx;
	}

	.update {
		position: absolute;
		left: 0;
		bottom: 6rpx;
		margin: 10rpx;
		font-size: 24rpx;
		color: #fff;
	}

	.list {
		display: flex;
		flex-direction: column;
		margin-left: 20rpx;
		margin-top: 30rpx;
	}

	.list-item {
		margin-bottom: 30rpx;
		font-size: 22rpx;
		color: #4c4c4c;
	}
</style>